package com.zlkj.pro.modular.app.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.zlkj.pro.modular.app.service.AppCustomerContactsService;
import com.zlkj.pro.modular.business.model.dto.CustomerContactsDTO;
import com.zlkj.pro.modular.business.model.vo.CustomerContactsVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.zlkj.pro.core.consts.ProjectConstants.SERVICE_APP_PREFIX;

/**
 * @author liyang
 * @date 2024/4/6
 * @time 14:34
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@ApiResource(name = "客户CustomerContactsDTO信息", path = SERVICE_APP_PREFIX + "/customer/contacts")
public class AppCustomerContactsController {

    private final AppCustomerContactsService appCustomerContactsService;

    @GetResource(name = "客户联系人列表", path = "/findList")
    public ResponseData findList(CustomerContactsDTO dto) {
        List<CustomerContactsVO> restData = appCustomerContactsService.findList(dto);
        return new SuccessResponseData(restData);
    }

    @GetResource(name = "查询联系人详情", path = "/findDetail")
    public ResponseData findDetail(CustomerContactsDTO dto) {
        CustomerContactsVO restData = appCustomerContactsService.findDetail(dto);
        return new SuccessResponseData(restData);
    }


    @PostResource(name = "添加联系人", path = "/add")
    public ResponseData add(@RequestBody CustomerContactsDTO dto) {
        boolean restData = appCustomerContactsService.add(dto);
        return new SuccessResponseData(restData);
    }

    @PostResource(name = "编辑联系人", path = "/edit")
    public ResponseData edit(@RequestBody CustomerContactsDTO dto) {
        boolean restData = appCustomerContactsService.edit(dto);
        return new SuccessResponseData(restData);
    }

    @PostResource(name = "编辑联系人", path = "/delete")
    public ResponseData delete(@RequestBody CustomerContactsDTO dto) {
        boolean restData = appCustomerContactsService.delete(dto);
        return new SuccessResponseData(restData);
    }

}
